package org.tastefuljava.minica;

import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.cert.X509Certificate;

public class CertificateEntry extends KeyStoreEntry {
    private X509Certificate cert;

    public CertificateEntry(String alias, X509Certificate cert) {
        super(alias, false);
        this.cert = cert;
    }

    public X509Certificate getCertificate() {
        return cert;
    }

    @Override
    public KeyStoreEntry copy(String newName) {
        return new CertificateEntry(newName, cert);
    }

    @Override
    public void addTo(KeyStore ks, char[] password) throws KeyStoreException {
        ks.setCertificateEntry(getAlias(), cert);
    }
}
